﻿//Copyright (c) Microsoft Corporation
//
//All rights reserved. 
//
//Licensed under the Apache License, Version 2.0 (the ""License""); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
//THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. 
//
//See the Apache Version 2.0 License for specific language governing permissions and limitations under the License.

using GalaSoft.MvvmLight;
using System.Runtime.Serialization;
using TED.WindowsAzure.Unplugged.Mobile.Sync.File;

namespace DPE.TED.OCAF.Win8SampleClient.ViewModels
{
    [DataContract]
    public class CommentsViewModel : ObservableObject
    {
        public CommentsViewModel(string commentID, string text, string filename, double x, double y, int page, double imageX = 0, double imageY = 0)
        {
            CommentID = commentID;
            Text = text;
            FileName = filename;
            X = x;
            Y = y;
            Page = page;
            OriginalImageX = imageX;
            OriginalImageY = imageY;
        }

        private string _CommentID = default(string);
        [DataMember]
        public string CommentID
        {
            get
            {
                return _CommentID;
            }

            set
            {
                _CommentID = value;
                RaisePropertyChanged("CommentID");
            }
        }

        private string _Text = default(string);
        [DataMember]
        public string Text
        {
            get
            {
                return _Text;
            }

            set
            {
                _Text = value;
                RaisePropertyChanged("Text");
            }
        }

        /// <summary>
        /// Name of the file on which this comment is being added
        /// </summary>
        private string _FileName = default(string);
        [DataMember]
        public string FileName
        {
            get
            {
                return _FileName;
            }

            set
            {
                _FileName = value;
                RaisePropertyChanged("FileName");
            }
        }

        private double _X = default(double);
        [DataMember]
        public double X
        {
            get
            {
                return _X;
            }

            set
            {
                _X = value;
                RaisePropertyChanged("X");
                RaisePropertyChanged("CommentHeader");
            }
        }
        
        private double _Y = default(double);
        [DataMember]
        public double Y
        {
            get
            {
                return _Y;
            }

            set
            {
                _Y = value;
                RaisePropertyChanged("Y");
                RaisePropertyChanged("CommentHeader");
            }
        }
        
        private int _Page = default(int);
        [DataMember]
        public int Page
        {
            get
            {
                return _Page;
            }

            set
            {
                _Page = value;
                RaisePropertyChanged("Page");
                RaisePropertyChanged("CommentHeader");
            }
        }

        private double _OriginalImageX = default(double);
        [DataMember]
        public double OriginalImageX
        {
            get
            {
                return _OriginalImageX;
            }

            set
            {
                _OriginalImageX = value;
                RaisePropertyChanged("OriginalImageX");
            }
        }
        
        private double _OriginalImageY = default(double);
        [DataMember]
        public double OriginalImageY
        {
            get
            {
                return _OriginalImageY;
            }

            set
            {
                _OriginalImageY = value;
                RaisePropertyChanged("OriginalImageY");
            }
        }

        private ISyncFile _syncFile = default(ISyncFile);
        [DataMember]
        public ISyncFile SyncFile
        {
            get
            {
                return _syncFile;
            }

            set
            {
                _syncFile = value;
                RaisePropertyChanged("LocalFile");
            }
        }
         
        public string CommentHeader
        { 
            get { return "Page: " + (Page + 1) + ", (" + X + ", " + Y + ")"; } 
        }
    }
}
